﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Swashbuckle.AspNetCore.Swagger;
using Swashbuckle.AspNetCore.SwaggerGen;

namespace IceDog.DNC.Web.Swashbuckle1_X.Filter
{
    /// <summary>
    /// 模型过滤器，判断是否是枚举
    /// </summary>
    public class PhoneNumberSchemaFilter : ISchemaFilter
    {
        public void Apply(Schema model, SchemaFilterContext context)
        {
            var typeInfo = context.SystemType.GetTypeInfo();

            if (typeInfo.IsEnum)
            {
                model.Extensions.Add("x-ms-enum", new { name = typeInfo.Name, modelAsString = true });
            };
        }
    }
}
